
 
	import flash.events.MouseEvent;

	private var colorDark:uint = 0x576069;//深色
	private var colorOver:uint = 0xF74461;//rollover
	private var colorBack:uint = 0xFFFFFF;//背景色
	
	private var isPlay:Boolean = true;
	
	private var isAutoplay:Boolean = true;//自动播放
	private var isShuffle:Boolean = false;//随机播放
	private var isLoop:Boolean = true;//循环播放

	
	/**
	 * 初始化
	 */		
	private function init():void{
		
		inner.addEventListener(MouseEvent.MOUSE_OVER,innerOver);
		inner.addEventListener(MouseEvent.MOUSE_OUT,innerOut);
		left.addEventListener(MouseEvent.MOUSE_OVER,leftOver);
		left.addEventListener(MouseEvent.MOUSE_OUT,leftOut);
		right.addEventListener(MouseEvent.MOUSE_OVER,rightOver);
		right.addEventListener(MouseEvent.MOUSE_OUT,rightOut);
		play.addEventListener(MouseEvent.MOUSE_OVER,playOver);
		play.addEventListener(MouseEvent.MOUSE_OUT,playOut);
		
		play.addEventListener(MouseEvent.CLICK,pausePlay);
		left.addEventListener(MouseEvent.CLICK,preSong);
		right.addEventListener(MouseEvent.CLICK,nextSong);
		var e:MouseEvent;
		innerOut(e);
		
		initBackGroundColor();
		drawLeftBtn(colorBack);
		drawRightBtn(colorBack);
		drawPauseBtn(colorDark);
	}
	
	
	
	private function nextSong(e:MouseEvent):void{
		nextPlay.play();
	}
	private function preSong(e:MouseEvent):void{
		prePlay.play();
	}
	private function pausePlay(e:MouseEvent):void{
		if(isPlay){//暂停播放
			isPlay = false;
			drawPlayBtn(colorOver);
			inner.visible = false;
			bg.width = 50;
			shadow_up.source = "Style/shadow2_up.png";
			shadow_down.source = "Style/shadow2_down.png";
		}
		else{//继续播放
			isPlay = true;
			drawPauseBtn(colorOver);
			inner.visible = true;
			bg.width = 290;
			shadow_up.source = "Style/shadow1_up.png";
			shadow_down.source = "Style/shadow1_down.png";
		}
	}
	
	
	/**
	 * 背景色
	 */
	private function initBackGroundColor():void{
		bg.setStyle("backgroundColor",colorBack);
	}
	/**
	 * 播放暂停的按钮 鼠标over out
	 */
	private function playOver(e:MouseEvent):void{
		if(isPlay)
			drawPauseBtn(colorOver);
		else
			drawPlayBtn(colorOver);
	}
	private function playOut(e:MouseEvent):void{
		if(isPlay)
			drawPauseBtn(colorDark);
		else
			drawPlayBtn(colorDark);
	}
	/**
	 * 播放暂停的按钮 draw
	 */
	private function drawPlayBtn(color:uint):void{
		play.graphics.clear();
		
		play.graphics.lineStyle(1,color,0);
		play.graphics.beginFill(color,0);
		play.graphics.moveTo(0,0);
		play.graphics.lineTo(0,18);
		play.graphics.lineTo(16,18);
		play.graphics.lineTo(16,0);
		play.graphics.endFill();
		
		play.graphics.lineStyle(1,color,1);
		play.graphics.beginFill(color,1);
		play.graphics.moveTo(2,2);
		play.graphics.lineTo(14,9);
		play.graphics.lineTo(2,16);
		play.graphics.endFill();
	}
	private function drawPauseBtn(color:uint):void{
		play.graphics.clear();
		
		play.graphics.lineStyle(1,color,0);
		play.graphics.beginFill(color,0);
		play.graphics.moveTo(0,0);
		play.graphics.lineTo(0,18);
		play.graphics.lineTo(16,18);
		play.graphics.lineTo(16,0);
		play.graphics.endFill();
		
		play.graphics.lineStyle(1,color,1);
		play.graphics.beginFill(color,1);
		play.graphics.drawRect(2,2,4,14);
		play.graphics.drawRect(10,2,4,14);
		play.graphics.endFill();
	}
	
	/**
	 * 上一首下一首的按钮 鼠标over out
	 */
	private function leftOver(e:MouseEvent):void{
		drawLeftBtn(colorOver);
	}
	private function leftOut(e:MouseEvent):void{
		drawLeftBtn(colorBack);
	}
	private function rightOver(e:MouseEvent):void{
		drawRightBtn(colorOver);
	}
	private function rightOut(e:MouseEvent):void{
		drawRightBtn(colorBack);
	}
	/**
	 * 上一首下一首的按钮 draw
	 */
	private function drawLeftBtn(color:uint):void{
		left.graphics.lineStyle(1,color,0);
		left.graphics.beginFill(color,0);
		left.graphics.moveTo(0,0);
		left.graphics.lineTo(0,10);
		left.graphics.lineTo(8,10);
		left.graphics.lineTo(8,0);
		left.graphics.endFill();
		
		left.graphics.lineStyle(1,color,1);
		left.graphics.beginFill(color,1);
		left.graphics.moveTo(4,2);
		left.graphics.lineTo(1,5);
		left.graphics.lineTo(4,8);
		left.graphics.endFill();
	}
	private function drawRightBtn(color:uint):void{
		right.graphics.lineStyle(1,color,0);
		right.graphics.beginFill(color,0);
		right.graphics.moveTo(0,0);
		right.graphics.lineTo(0,10);
		right.graphics.lineTo(8,10);
		right.graphics.lineTo(8,0);
		right.graphics.endFill();
		
		right.graphics.lineStyle(1,color,1);
		right.graphics.beginFill(color,1);
		right.graphics.moveTo(2,2);
		right.graphics.lineTo(5,5);
		right.graphics.lineTo(2,8);
		right.graphics.endFill();
	}

	/**
	 * 中间区域 鼠标over out
	 */
	private function innerOver(e:MouseEvent):void{
		inner.setStyle("backgroundColor",colorDark);
		inner.setStyle("borderColor",colorDark);
		song.setStyle("color",colorBack);
	}
	private function innerOut(e:MouseEvent):void{
		inner.setStyle("backgroundColor",colorBack);
		inner.setStyle("borderColor",colorBack);
		song.setStyle("color",colorDark);
	}
